#include "bus.h"

MessageBus g_bus;

const std::string topic = "drive";

struct Subject {
    void send(const std::string& topic) {
        g_bus.send<void, int>(50, topic);
    }
};


struct Car {
    Car(){
        g_bus.attach([this](int speed) { drive(speed); }, topic);
    }
    void drive(int speed) {
        std::cout << "Car Drive: " << speed << std::endl;
    }
};

struct Bus {
    Bus(){
        g_bus.attach([this](int speed) { drive(speed); }, topic);
    }
    void drive(int speed) {
        std::cout << "Bus Drive: " << speed << std::endl;
    }
};

int bus() {
    Subject sub;


    Car car;
    Bus bus;
    sub.send(topic);
    sub.send("");

    g_bus.remove<void, int>();
    sub.send("");

    return 0;
}